<html>
<header>
  <meta charset="utf-8" />
  <link href="<%=staticRelativePath%>/normalize.css" rel="stylesheet" type="text/css" />
  <link rel="stylesheet" href="<%=staticRelativePath%>/iconfont/iconfont.css">
  <style type="text/css">
    table {
      width: 100%;
    }

    table,
    th,
    td {
      border: 1px solid black;
      text-align: center;
    }

    table>thead {
      background-color: #88898B;
      color: white;
    }

    .testcase-tr {
      background-color: #C8C9CA;
    }

    .hide-td-border {
      border: none;
    }

    .colspan-text-align {
      text-align: start;
    }

    .function-count {
      text-align: end;
    }

    .function-test-count {
      text-align: end;
    }

    .test-result-succeed {
      color: #4DD5B3;
    }

    .test-result-nonStrictSucceed {
      color: #BF901D;

    }

    .test-result-failed {
      color: #CC3E35;
    }

    .test-result-exception {
      color: #FFBB36;
    }

    .test-result-codeDefect {
      color: #DE640F;
    }

    .test-result-noResult {
      color: #7B7B7B;
    }

    .test-result-unknown {
      color: #5188F4;
    }
    .back-to-top {
      margin: 20px;
      text-align: center;
    }
    a {
        text-decoration: none;
     }
    a:visited {
       color: #00e; 
       text-decoration: none; /* 去掉下划线等文本修饰 */
    }
  </style>
</header>

<body style="padding-top: 15px;">

  <div id = "top" style="text-align: center">
    <h1>单元测试报告总览</h1>
  </div>
  <div style="text-align: right;"><span>日期：<%=reportTime%>&nbsp;&nbsp;</span></div>
  <div>
    <table>
      <tbody>
        <tr>
          <td>项目名称</td>
          <td colspan="2">
            <%=overview.projectName%>
          </td>
        </tr>
        <tr>
          <td>版本号</td>
          <td colspan="2">
            <%=overview.versionName%>
          </td>
        </tr>
        <tr>
          <td rowspan="7">测试概况(测试对象统计)</td>
          <td>
            <% if(jumpable){%>
            <a href = "#sourceFileCoverage">源文件（个）</a>
            <%} else {%>
              源文件（个）
            <%}%>
          </td>
          <td>
            <%=overview.sourceFileCount%>
          </td>
        </tr>
        <tr>
          <td>头文件（个）</td>
          <td>
            <%=overview.headerFileCount%>
          </td>
        </tr>
        <tr>
          <td>
            <% if(jumpable){%>
              <a href="#functionCoverage">函数（个）</a>
              <%} else {%>
                函数（个）
            <%}%>
          </td>
          <td>
            <%=overview.functionCount%>
          </td>
        </tr>
        <tr>
          <td>
            <% if(jumpable){%>
              <a href="#functionCoverage">函数通过数（个）</a>
              <%} else {%>
                函数通过数（个）
            <%}%>
          </td>
          <td>
            <%=functionResultsStatistic.passed%>
          </td>
        </tr>
        <tr>
          <td rowspan="3">代码行数</td>
          <td>总行数：<%=overview.numberOfLines%>
          </td>
        </tr>
        <tr>
          <td>源文件行数：<%=overview.sourceNumberOfLines%>
          </td>
        </tr>
        <tr>
          <td>头文件行数：<%=overview.headerNumberOfLines%>
          </td>
        </tr>
        <% for( let index = 0; index < enabledCoverageKind.length; index++ ) { %>
          <tr>
            <% if (index === 0) { %>
              <td rowspan="<%= 2 * enabledCoverageKind.length %>">覆盖概况(<% if (coverageRange === 1) { %>测试对象统计<% } else { %>所选文件函数统计<% } %>)</td>
            <% } %>
            <td rowspan="2"><%=enabledCoverageKind[index].name%></td>
            <td><%=overview[enabledCoverageKind[index].coverageKey]%></td>
          </tr>
          <tr>
            <td><%=overview[enabledCoverageKind[index].coveredKey]%>/<%=overview[enabledCoverageKind[index].totalKey]%></td>
          </tr>
        <% } %>
      </tbody>

    </table>
  </div>

  <h2>覆盖率分布图</h2>
  <p><span>&nbsp;&nbsp;&nbsp;&nbsp; 以下数据是将覆盖率分为5个区间，每个区间分别显示落在该区间的语句、分支、条件、决策以及MC/DC的函数个数。</span></p>
  <p style="text-align: center;"><img width="100%" src="<%=coverageDistributionImage%>"></p>
  <p style="text-align: center;"><span>图1: 覆盖率分布结果统计</span></p>

  <h2>测试用例统计</h2>
  <p><span>&nbsp;&nbsp;&nbsp;&nbsp; 以下数据是统计测试用例在通过、通过*、未通过、执行异常、运行时错误、无结果以及未执行七种的用例个数。</span></p>
  <div style="float: left; width: 40%;">
    <table>
      <tr>
        <th>用例总数</th>
        <th><%=testsOverview.total%></th>
      </tr>
      
      <tr>
        <td><span class="icon iconfont icon-icon-pass test-result-succeed"></span>&nbsp通过</td>
        <td><%=testsOverview.succeed%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-icon-pass test-result-nonStrictSucceed"></span>&nbsp通过*</td>
        <td><%=testsOverview.nonStrictSucceed%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-icon-nopass test-result-failed"></span>&nbsp未通过</td>
        <td><%=testsOverview.failed%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-icon-warning test-result-exception"></span>&nbsp执行异常</td>
        <td><%=testsOverview.exception%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-code-defect test-result-codeDefect"></span>&nbsp运行时错误</td>
        <td><%=testsOverview.codeDefect%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-icon-no-result test-result-noResult"></span>&nbsp无结果</td>
        <td><%=testsOverview.noResult%></td>
      </tr>
      <tr>
        <td><span class="icon iconfont icon-unanalysis test-result-unknown"></span>&nbsp未执行</td>
        <td><%=testsOverview.unknown%></td>
      </tr>
    </table>
  </div>
  <div style="float: left; width:40%; margin-left: 100px;">
    <img width="100%" src="<%=testCaseResultsImage%>">
    <p style="text-align: center;"><span>图2: 用例执行结果统计</span></p>
  </div>
  <div style="clear: both;"></div>
  <h2>测试函数统计</h2>
  <p><span>&nbsp;&nbsp;&nbsp;&nbsp; 以下数据是统计测试函数在通过、未通过以及未定义三种结果的函数个数。</span></p>
  <div style="float: left; width: 40%;">
    <table>
      <tr>
        <th>函数总数</th>
        <th><%=overview.functionCount%></th>
      </tr>
      <tr>
        <td>通过</td>
        <td><%=functionResultsStatistic.passed%></td>
      </tr>
      <td>未通过</td>
      <td><%=functionResultsStatistic.failed%></td>
      </tr>
      <td>未定义</td>
      <td><%=functionResultsStatistic.undefined%></td>
      </tr>
    </table>
  </div>
  <div style="float: left; width:40%; margin-left: 100px;">
    <img width="100%" src="<%=functionResultsImage%>">
    <p style="text-align: center;"><span>图3: 函数执行结果统计</span></p>
  </div>
  <div style="clear: both;"></div>

  <h2>用例/函数结果说明</h2>
  <table>
    <tr>
      <th>用例结果</th>
      <th>函数结果</th>
      <th>说明</th>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-icon-pass test-result-succeed"></span>&nbsp通过</td>
      <td rowspan="2">通过</td>
      <td>用例执行通过，预期值与实际值相等。当前函数所有用例执行通过，则函数执行结果为通过。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-icon-pass test-result-nonStrictSucceed"></span>&nbsp通过*</td>
      <td>用例执行通过，无预期值。
        配置信息中没有勾选“未设定预期值时，不可通过，视为无结果”。
        当前函数所有用例执行为通过/通过*，则函数执行结果为通过。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-icon-nopass test-result-failed"></span>&nbsp未通过</td>
      <td rowspan="3">未通过</td>
      <td>用例执行不通过，预期值与实际值不相等。
        当前函数对应用例执行存在未通过，则函数执行结果为未通过。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-icon-warning test-result-exception"></span>&nbsp执行异常</td>
      <td>用例执行出现异常。
        当前函数对应用例执行存在执行异常，则函数执行结果为未通过。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-code-defect test-result-codeDefect"></span>&nbsp运行时错误</td>
      <td>用例执行出现运行时错误。
        当前函数对应用例执行存在运行时错误，则函数执行结果为未通过。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-icon-no-result test-result-noResult"></span>&nbsp无结果</td>
      <td rowspan="2">未定义</td>
      <td>用例执行通过，无预期值。
        配置信息中勾选了“未设定预期值时，不可通过，视为无结果”。
        当前函数对应用例执行全部为无结果或在通过/通过*中包含无结果，则函数执行结果为未定义。</td>
    </tr>
    <tr>
      <td><span class="icon iconfont icon-unanalysis test-result-unknown"></span>&nbsp未执行</td>
      <td>用例未执行。
        当前函数存在未执行的用例，则函数执行结果为未定义。</td>
    </tr>
  </table>
  <% if(jumpable){%>
    <div class="back-to-top">[ <a href="#top">返回开始</a> ]</div>
  <%}%>
  <h2 id = "sourceFileCoverage" >源文件覆盖率信息统计</h2>
  <p><span>共有<%=overview.sourceFileCount%>个源文件，解析成功有<%=sourceFileStatusCount[205]%>个，解析失败有<%=sourceFileStatusCount[204]%>个，未解析有<%=sourceFileStatusCount[201]%>个，待解析有<%=sourceFileStatusCount[206]%>个。</span></p>
  <table>
    <tr>
      <th>文件名</th>
      <th>函数(个)</th>
      <th>用例(个)</th>
      <th>代码(行)</th>
      <% for( let index = 0; index < enabledCoverageKind.length; index++ ) { %>
        <th><%= enabledCoverageKind[index].name %></th>
      <% } %>
    </tr>
    <% for( let index = 0; index < sourceFilesOverview.length; index++ ) { 
      const { functionCount, fileName, testCount, numberOfLines, coverageInfo, path } = sourceFilesOverview[index];
      const filePath = `${path}.html`;%>
      <tr>
        <td rowspan="2">
        <% if(jumpable && testCount > 0 && !noFiles){%>
            <a href= "<%= filePath %>" target="_blank"><%= fileName%></a>
        <%} else {%>
            <%= fileName%>
        <%}%>
        </td>

        <td rowspan="2"><%=functionCount%></td>
        <td rowspan="2"><%=testCount%></td>
        <td rowspan="2"><%=numberOfLines%></td>
        <% for( let index = 0; index < coverageInfo.length; index++ ) { %>
          <td><%= coverageInfo[index].coverage %></td>
        <% } %>
      </tr>
      <tr>
        <% for( let index = 0; index < coverageInfo.length; index++ ) { %>
          <td><%= coverageInfo[index].covered%>/<%=coverageInfo[index].total %></td>
        <% } %>
      </tr>
    <% } %>
    
  </table>
  <% if(jumpable){%>
    <div class="back-to-top">[ <a href="#top">返回开始</a> ｜ <a href="#sourceFileCoverage">返回本节</a> ]</div>
  <%}%>
  <h2 id = "functionCoverage" >函数覆盖率信息统计</h2>
  <p><span>共有<%=overview.functionCount%>个函数，通过<%=functionResultsStatistic.passed%>个。</span></p>
  <table>
    <tr>
      <th>函数名</th>
      <th>所属文件名</th>
      <th>用例个数</th>
      <% for( let index = 0; index < enabledCoverageKind.length; index++ ) { %>
        <th><%=enabledCoverageKind[index].name%></th>
      <% } %>
      <th>执行结果</th>
    </tr>
    <% for( let index = 0; index < functionsOverview.length; index++ ) {
      const { functionName, fileName, testCount, coverageInfo, resultKind, filePath } = functionsOverview[index]; 
      const newFilePath = `${filePath}.html`;
      const fileFuncPath = `${newFilePath}#${functionName}`; %>
      <tr>
        <td rowspan="2">
          <% if(jumpable && testCount > 0 && !noFiles){%>
            <a href= "<%= fileFuncPath %>" target="_blank"><%= functionName%></a>
          <%} else {%>
            <%= functionName%>
          <%}%>
        </td>
        <td rowspan="2">
          <% if(jumpable && testCount > 0 && !noFiles){%>
            <a href= "<%= newFilePath %>" target="_blank"><%= fileName%></a>
          <%} else {%>
            <%= fileName%>
          <%}%>
        </td>
        <td rowspan="2"><%=testCount%></td>
        <% for( let index = 0; index < coverageInfo.length; index++ ) { %>
          <td><%=coverageInfo[index].coverage%></td>
        <% } %>
        <td rowspan="2"><%=resultKind%></td>
      </tr>
      <tr>
        <% for( let index = 0; index < coverageInfo.length; index++ ) { %>
          <td><%=coverageInfo[index].covered%>/<%=coverageInfo[index].total%></td>
        <% } %>
      </tr>
    <% } %>
    
  </table>
  <% if(jumpable){%>
    <div class="back-to-top">[ <a href="#top">返回开始</a> ｜ <a href="#functionCoverage">返回本节</a> ]</div>
  <%}%>
</body>

</html>
